package org.wu.framework.authorization.platform.application.impl;

import org.wu.framework.lazy.orm.web.plus.stereotype.LazyApplication;
import org.wu.framework.authorization.platform.application.LazyZoneApplicationApplication;
import org.wu.framework.web.response.Result;
import org.wu.framework.authorization.platform.domain.model.lazy.zone.application.LazyZoneApplication;
import org.wu.framework.authorization.platform.application.command.lazy.zone.application.LazyZoneApplicationRemoveCommand;
import org.wu.framework.authorization.platform.application.command.lazy.zone.application.LazyZoneApplicationStoryCommand;
import org.wu.framework.authorization.platform.application.command.lazy.zone.application.LazyZoneApplicationUpdateCommand;
import org.wu.framework.authorization.platform.application.command.lazy.zone.application.LazyZoneApplicationQueryListCommand;
import org.wu.framework.authorization.platform.application.command.lazy.zone.application.LazyZoneApplicationQueryOneCommand;
import org.wu.framework.authorization.platform.application.assembler.LazyZoneApplicationDTOAssembler;
import org.wu.framework.authorization.platform.application.dto.LazyZoneApplicationDTO;
import java.util.stream.Collectors;
import jakarta.annotation.Resource;
import org.wu.framework.authorization.platform.domain.model.lazy.zone.application.LazyZoneApplicationRepository;
import java.util.List;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
/**
 * describe 应用信息 
 *
 * @author Jia wei Wu
 * @date 2024/04/02 06:21 晚上
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyApplicationImpl 
 **/
@LazyApplication
public class LazyZoneApplicationApplicationImpl implements LazyZoneApplicationApplication {

    @Resource
    LazyZoneApplicationRepository lazyZoneApplicationRepository;
    /**
     * describe 新增应用信息
     *
     * @param lazyZoneApplicationStoryCommand 新增应用信息     
     * @return {@link Result<LazyZoneApplication>} 应用信息新增后领域对象     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<LazyZoneApplication> story(LazyZoneApplicationStoryCommand lazyZoneApplicationStoryCommand) {
        LazyZoneApplication lazyZoneApplication = LazyZoneApplicationDTOAssembler.INSTANCE.toLazyZoneApplication(lazyZoneApplicationStoryCommand);
        return lazyZoneApplicationRepository.story(lazyZoneApplication);
    }
    /**
     * describe 批量新增应用信息
     *
     * @param lazyZoneApplicationStoryCommandList 批量新增应用信息     
     * @return {@link Result<List<LazyZoneApplication>>} 应用信息新增后领域对象集合     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<List<LazyZoneApplication>> batchStory(List<LazyZoneApplicationStoryCommand> lazyZoneApplicationStoryCommandList) {
        List<LazyZoneApplication> lazyZoneApplicationList = lazyZoneApplicationStoryCommandList.stream().map( LazyZoneApplicationDTOAssembler.INSTANCE::toLazyZoneApplication).collect(Collectors.toList());
        return lazyZoneApplicationRepository.batchStory(lazyZoneApplicationList);
    }
    /**
     * describe 更新应用信息
     *
     * @param lazyZoneApplicationUpdateCommand 更新应用信息     
     * @return {@link Result<LazyZoneApplication>} 应用信息领域对象     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<LazyZoneApplication> updateOne(LazyZoneApplicationUpdateCommand lazyZoneApplicationUpdateCommand) {
        LazyZoneApplication lazyZoneApplication = LazyZoneApplicationDTOAssembler.INSTANCE.toLazyZoneApplication(lazyZoneApplicationUpdateCommand);
        return lazyZoneApplicationRepository.story(lazyZoneApplication);
    }

    /**
     * describe 查询单个应用信息
     *
     * @param lazyZoneApplicationQueryOneCommand 查询单个应用信息     
     * @return {@link Result<LazyZoneApplicationDTO>} 应用信息DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<LazyZoneApplicationDTO> findOne(LazyZoneApplicationQueryOneCommand lazyZoneApplicationQueryOneCommand) {
        LazyZoneApplication lazyZoneApplication = LazyZoneApplicationDTOAssembler.INSTANCE.toLazyZoneApplication(lazyZoneApplicationQueryOneCommand);
        return lazyZoneApplicationRepository.findOne(lazyZoneApplication).convert(LazyZoneApplicationDTOAssembler.INSTANCE::fromLazyZoneApplication);
    }

    /**
     * describe 查询多个应用信息
     *
     * @param lazyZoneApplicationQueryListCommand 查询多个应用信息     
     * @return {@link Result<List<LazyZoneApplicationDTO>>} 应用信息DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<List<LazyZoneApplicationDTO>> findList(LazyZoneApplicationQueryListCommand lazyZoneApplicationQueryListCommand) {
        LazyZoneApplication lazyZoneApplication = LazyZoneApplicationDTOAssembler.INSTANCE.toLazyZoneApplication(lazyZoneApplicationQueryListCommand);
        return lazyZoneApplicationRepository.findList(lazyZoneApplication)        .convert(lazyZoneApplications -> lazyZoneApplications.stream().map(LazyZoneApplicationDTOAssembler.INSTANCE::fromLazyZoneApplication).collect(Collectors.toList())) ;
    }

    /**
     * describe 分页查询多个应用信息
     *
     * @param lazyZoneApplicationQueryListCommand 分页查询多个应用信息     
     * @return {@link Result<LazyPage<LazyZoneApplicationDTO>>} 分页应用信息DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<LazyPage<LazyZoneApplicationDTO>> findPage(int size,int current,LazyZoneApplicationQueryListCommand lazyZoneApplicationQueryListCommand) {
        LazyZoneApplication lazyZoneApplication = LazyZoneApplicationDTOAssembler.INSTANCE.toLazyZoneApplication(lazyZoneApplicationQueryListCommand);
        return lazyZoneApplicationRepository.findPage(size,current,lazyZoneApplication)        .convert(page -> page.convert(LazyZoneApplicationDTOAssembler.INSTANCE::fromLazyZoneApplication))            ;
    }

    /**
     * describe 删除应用信息
     *
     * @param lazyZoneApplicationRemoveCommand 删除应用信息     
     * @return {@link Result<LazyZoneApplication>} 应用信息     
     
     * @author Jia wei Wu
     * @date 2024/04/02 06:21 晚上
     **/

    @Override
    public Result<LazyZoneApplication> remove(LazyZoneApplicationRemoveCommand lazyZoneApplicationRemoveCommand) {
     LazyZoneApplication lazyZoneApplication = LazyZoneApplicationDTOAssembler.INSTANCE.toLazyZoneApplication(lazyZoneApplicationRemoveCommand);
     return lazyZoneApplicationRepository.remove(lazyZoneApplication);
    }

}